package com.google.code.hibernate.rest.example.json;

import static org.junit.Assert.assertEquals;

import java.io.IOException;

import net.sf.json.JSONObject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.code.hibernate.rest.internal.InternalStreams;

/**
 * 
 * @author wangzijian
 * 
 */
public class Examples {
	
	private static final Logger LOGGER = LoggerFactory.getLogger(Examples.class);
	
	private Examples() {
	}

	public static String contentOf(String file) throws IOException {
		return InternalStreams.read(Examples.class.getResourceAsStream(file));
	}

	public static void assertJSONEquals(String expected, String actual) {
		JSONObject expectedJSON = JSONObject.fromObject(expected);
		JSONObject actualJSON = JSONObject.fromObject(actual);
		LOGGER.info("Expected -> " + expectedJSON.toString());
		LOGGER.info("Actual   -> " + actualJSON.toString());
		assertEquals(expectedJSON, actualJSON);
	}
}
